//package chat.demo.server.handler;
//
//import io.netty.channel.ChannelHandlerContext;
//import io.netty.channel.ChannelInboundHandlerAdapter;
//import io.netty.handler.timeout.IdleState;
//import io.netty.handler.timeout.IdleStateEvent;
//
//public class HeartbeatHandler extends ChannelInboundHandlerAdapter {
//    @Override
//    public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
//        if (evt instanceof IdleStateEvent) {
//            IdleStateEvent idleStateEvent = (IdleStateEvent) evt;
//            if (idleStateEvent.state() == IdleState.READER_IDLE) {
//                System.out.println("read free time limit triggered");
//            } else if (idleStateEvent.state() == IdleState.WRITER_IDLE) {
//                System.out.println("write free time limit triggered");
//            } else if (idleStateEvent.state() == IdleState.ALL_IDLE) {
//                System.out.println("====================");
//                System.out.println("Both read and write time limit triggered");
//                System.out.println("close the channel");
//                System.out.println("====================");
//                ctx.channel().close();
//            }
//        }
//    }
//
//
//}
